#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<assert.h>
#include<stdlib.h>


typedef int BTDataType;

typedef struct BinaryTreeNode
{
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;
	BTDataType data;
}BTNode;

BTNode* BuyNode(BTDataType x)
{
	BTNode* root = malloc(sizeof(BTNode));
	assert(root);
	root->data = x;
	root->left = NULL;
	root->right = NULL;
}

BTNode* CreatBinaryTree()
{
	BTNode* node1 = BuyNode(1);
	BTNode* node2 = BuyNode(2);
	BTNode* node3 = BuyNode(3);
	BTNode* node4 = BuyNode(4);
	BTNode* node5 = BuyNode(5);
	BTNode* node6 = BuyNode(6);

	node1->left = node2;
	node1->right = node4;
	node2->left = node3;
	node4->left = node5;
	node4->right = node6;

	return node1;
}
void preOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("# ");
		return;
	}
	printf("%d ", root->data);
	preOrder(root->left);
	preOrder(root->right);
}

void inOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("# ");
		return;
	}

	inOrder(root->left);
	printf("%d ", root->data);
	inOrder(root->right);
}

void postOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("# ");
		return;
	}

	postOrder(root->left);
	postOrder(root->right);
	printf("%d ", root->data);
}


int main()
{
	BTNode* root = CreatBinaryTree();
	preOrder(root);
	printf("\n");
	inOrder(root);
	printf("\n");
	postOrder(root);
	return 0;
}